<?php
	function replaceUrl($url, $param, $value){
	
		if($value.strpos('=') > 0){
			
			$value = substr($value, $value.strpos('=')+1);
		}
		if($url.strpos($param) >= 0){
			
			var $temp = substr($url,$url.strpos($param));
			
			if(substr($temp, 1).strpos('&') > 0){
				
				$temp = substr($temp,0, substr($temp, 1).strpos('&')+1);
			}
			if($value == ''){
				
				$url = str_replace($temp, '', $url);
			}else{
				
				$url = str_replace($temp, $param.$value, $url);
			}
		}else if($value != ''){
			
			$url .= $param.$value;
		}
		return $url;
	}
?>